package boot

import (
	"context"
	"gf-xb-api/internal/consts"

	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/os/gtime"
)

func init() {

	var ctx = context.Background()

	var timeZoneStr string
	timeZone, _ := g.Config().Get(ctx, consts.SERVER_TIMEZONE)
	if timeZone == nil {
		timeZoneStr = "Asia/Shanghai"
	} else {
		timeZoneStr = timeZone.String()
	}

	// 设置全局时区
	err := gtime.SetTimeZone(timeZoneStr)
	if err != nil {
		panic(err)
	}
}
